#include "PlayFileDiag.h"

BEGIN_EVENT_TABLE( PlayFileDiag, wxDialog )
	EVT_BUTTON(wxID_PlayOK, PlayFileDiag::OnOk)
	EVT_CHOICE(wxID_PlayDEV,PlayFileDiag::ControlDevice)
END_EVENT_TABLE()

PlayFileDiag::PlayFileDiag(wxWindow *parent, int *ch, int *freq, double *res, double *digmax, double *digmin, double* offset) :  PlayFile_Dlg(parent)
{
	nCh = ch;
	pSFreq = freq;
	pRes = res;
	pDigMax = digmax;
	pDigMin = digmin;
	pOffset = offset;
}

PlayFileDiag::~PlayFileDiag(void)
{
}

void PlayFileDiag::OnOk(wxCommandEvent& event)
{

	*nCh = wxAtoi(this->NCH->GetLabel());
	*pSFreq = wxAtoi(this->SFreq->GetLabel());
	this->Res->GetLabel().ToDouble(pRes);
	this->DigMin->GetLabel().ToDouble(pDigMin);
	this->DigMax->GetLabel().ToDouble(pDigMax);
	this->DigOff->GetLabel().ToDouble(pOffset);
	this->Close();

}

void PlayFileDiag::ControlDevice(wxCommandEvent& event)
{
	if ((this->selDev->GetCurrentSelection()>0) && (this->selDev->GetCurrentSelection()<4))
	{
		this->NCH->Disable();
		this->SFreq->Disable();
		this->Res->Disable();
		this->DigMin->Disable();
		this->DigMax->Disable();
		this->DigOff->Disable();
	}
	switch(this->selDev->GetCurrentSelection())
	{
	case 1: //PLE
		this->SFreq->Enable();
		this->NCH->SetSelection(7);
		this->SFreq->SetSelection(3);
		this->Res->SetSelection(1);
		this->DigMin->SetSelection(0);
		this->DigMax->SetSelection(1);
		this->DigOff->SetSelection(1);
		break;
	case 2: //Bluesilk
		this->SFreq->Enable();
		this->NCH->SetSelection(7);
		this->SFreq->SetSelection(3);
		this->Res->SetSelection(0);
		this->DigMin->SetSelection(0);
		this->DigMax->SetSelection(1);
		this->DigOff->SetSelection(1);
		break;
	case 3: //GMobiLab
		this->NCH->SetSelection(7);
		this->SFreq->SetSelection(3);
		this->Res->SetSelection(3);
		this->DigMin->SetSelection(10);
		this->DigMax->SetSelection(3);
		this->DigOff->SetSelection(0);
		break;
	case 4: //gUSBamp
		this->NCH->Enable();
		this->SFreq->Enable();
		this->NCH->SetSelection(15);
		this->SFreq->SetSelection(3);
		this->Res->SetSelection(2);
		this->DigMin->SetSelection(12);
		this->DigMax->SetSelection(5);
		this->DigOff->SetSelection(0);
		break;
	case 5: //BrainBox
		this->NCH->Enable();
		this->SFreq->Enable();
		this->Res->Enable();
		this->NCH->SetLabel(wxT("32"));
		this->SFreq->SetSelection(3);
		this->Res->SetSelection(1);
		this->DigMin->SetLabel(wxT("5000"));
		this->DigMax->SetLabel(wxT("-5000"));
		this->DigOff->SetSelection(0);
		break;
	default:
		this->NCH->Enable();
		this->SFreq->Enable();
		this->Res->Enable();
		this->DigMin->Enable();
		this->DigMax->Enable();
		this->DigOff->Enable();
		break;
	}
	



}